package com.projectmanagement.server.controller;


import com.alibaba.fastjson.JSON;
import com.projectmanagement.server.dao.entity.bo.PageObject;
import com.projectmanagement.server.service.serviceImpl.CaseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @description
 * @author 星空梦语
 * @date 2021/3/9 下午4:08
 */
@Controller
@RequestMapping("/case")
public class CaseController {

    @Resource
    private CaseService caseService;


    /**
     * @description
     * @author 星空梦语
     * @date 2021/3/9 下午4:08
     */
    @ResponseBody
    @RequestMapping(value = "/queryAll",produces = "application/json;charset=utf-8")
    public String queryAll(HttpServletRequest request, @RequestBody PageObject pageObject) throws Exception {
        return caseService.queryAll(request,pageObject);
    }

    /**
     * @description
     * @author 星空梦语
     * @date 2021/3/9 下午4:08
     */
    @ResponseBody
    @RequestMapping(value = "/queryChild",produces = "application/json;charset=utf-8")
    public String queryChild(HttpServletRequest request,@RequestBody PageObject pageObject) throws Exception {
        return JSON.toJSONString(caseService.queryChild(request,pageObject));
    }


    /**
     * @description
     * @author 星空梦语
     * @date 2021/3/9 下午4:08
     */
    @ResponseBody
    @RequestMapping(value = "/removeCase",produces = "application/json;charset=utf-8")
    public void removeCase(@RequestBody PageObject pageObject) throws Exception {
        caseService.removeCase(pageObject);
    }

    /**
     * @description
     * @author 星空梦语
     * @date 2021/3/9 下午4:08
     */
    @ResponseBody
    @RequestMapping(value = "/saveCase",produces = "application/json;charset=utf-8")
    public void saveCase(@RequestBody PageObject pageObject) throws Exception {
        caseService.saveCase(pageObject);
    }

    /**
     * @description
     * @author 星空梦语
     * @date 2021/3/9 下午4:08
     */
    @ResponseBody
    @RequestMapping(value = "/runCase",produces = "application/json;charset=utf-8")
    public void runCase(HttpServletRequest request, @RequestBody PageObject pageObject) throws Exception {
        caseService.runCase(request,pageObject);
    }





}
